<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 随机生成（100-999）并取出百位，十位，个位
    var num = Math.round(100 + Math.random() * 899);
    var x = 0, y = 0, z = 0;
    x = num / 100;
    y = (num / 10) % 10;
    z = num % 10;
    console.log(num);
    console.log(" 百位数为：" + parseInt(x) + "\n", "十位数为：" + parseInt(y) + "\n", "个位数为：" + parseInt(z));

    //1234567秒，转成多少天多少小时多少分多少秒
    // var time = prompt("请输入时间：");
    var time=1234567;
    var min, hour, day, x, y, sec;
    day = time / 86400;
    x = time % 86400;

    hour = x / 3600;
    y = x % 3600;

    min = y / 60;
    sec = y % 60;
    console.log(parseInt(day) + "天" + parseInt(hour) + "个小时" + parseInt(min) + "分" + "零" + parseInt(sec) + "秒");
</script>

</html>